package com.woniu;

import io.jsonwebtoken.Claims;
import io.jsonwebtoken.Jwts;

/**
 * @author:陈涵
 * @Do:解析token
 * @date: 2022/9/5 15:28
 */
public class ParseJWTDemo {
    public static void main(String[] args) {
        String token ="eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiJ3b25pdSIsInN1YiI6IueuoeeQhuWRmCIsImlhdCI6MTY2MjM3NTY5MiwiZXhwIjoxNjYyMzc1OTkyLCJhY2NvdW50IjoiYWRtaW4iLCJzdGF0dXMiOiJZIn0.uS29HsgqazrIbBHq0s4-y0BD34r9iHO4j4QMQkvn2r0";
        //使用Jwts，需要解析圣体中存入的信息
        Claims claims = Jwts.parser().setSigningKey("chenxian").parseClaimsJws(token).getBody();
        System.out.println(claims.getId());
        System.out.println(claims.getIssuedAt());
        System.out.println(claims.getSubject());
        System.out.println(claims.get("account"));
        System.out.println(claims.get("status"));
        System.out.println(claims.getExpiration());
    }
}
